<?php

namespace app\logic\model\user;

use app\logic\model\LogicModel;
use think\model\concern\SoftDelete;

class UserTypeLogicModel extends LogicModel
{
    use SoftDelete;
    protected $name='user_type';

    public static function getByIds(array $type_ids)
    {
        return self::whereIn('id',$type_ids)->column('title','id');
    }


    function getList($request,$where=[],$filed="*",$page=1,$limit=15,$order="id desc"){
        $query=$this->where($where)
            ->where(function ($q) use ($request){
                if(check_request($request,'title')){
                    $q->whereLike("title","%{$request['title']}%");
                }
            });
        $list = $query->field($filed)->order($order)->page($page,$limit)->select();
        $count = $query->count();
        return [$list,$count];
    }
}